package com.bnlr.lrparking.appui.mine.setting;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.bnlr.lrparking.R;
import com.bnlr.lrparking.appui.login.VerificaActivity;
import com.bnlr.lrparking.appui.web.WebActivity;
import com.bnlr.lrparking.base.BaseActivity;
import com.bnlr.lrparking.app.AppConfig;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * 关于我们
 *
 * @author hp
 */
public class AboutActivity extends BaseActivity {
    private Unbinder unbinder;
    @BindView(R.id.tv_about_version)
    TextView tvAboutVersion;
    @BindView(R.id.tv_nav_title)
    TextView tvNavTitle;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about);
        unbinder = ButterKnife.bind(this);
        tvNavTitle.setText("关于我们");
        tvAboutVersion.setText("利人停车 V" + AppUtils.getAppVersionName());
    }

    @OnClick({R.id.rl_about_like, R.id.rl_about_complain, R.id.tv_about_cause})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.rl_about_like:
                ToastUtils.showShort("非常感谢您的点赞支持");
              //  launchAppDetail("com.bnlr.lrparking","com.tencent.android.qqdownloader");
                break;
            case R.id.rl_about_complain:
                if (!AppConfig.getInstance().getBoolean("isLogin",false)) {
                    startActivity(VerificaActivity.class);
                    return;
                }
                startActivity(EditFankuiActivity.class);
                break;
            case R.id.tv_about_cause:
               Intent intent=new Intent(baseContext,WebActivity.class);
                intent.putExtra("tag",3);
                startActivity(intent);
                break;
            default:
                break;
        }
    }



    @Override
    protected void onDestroy() {
        super.onDestroy();
        unbinder.unbind();
    }


    public void launchAppDetail(String appPkg, String marketPkg) {
        try {
            if (TextUtils.isEmpty(appPkg)) {
                return;
            }

            Uri uri = Uri.parse("market://details?id=" + appPkg);
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            if (!TextUtils.isEmpty(marketPkg)) {
                intent.setPackage(marketPkg);
            }
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
